#!/usr/bin/env python

##  flamingo - 2D Game Engine
##  Copyright (C) 2009 Bradley Zeis
##
##  This program is free software: you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation, either version 3 of the License, or
##  (at your option) any later version.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##  Bradley Zeis
##  flamingoengine@gmail.com

class _Data(object):
    """Contains data necessary to run the Game.

    All instances share the same state, so every instance created will
    have exact replicas of the data. They will also all update their
    data automatically if you change the data in one instance.
    """
    _shared_state = {}
    def __init__(self):
        self.__dict__ = self._shared_state

    ##-------- Metadata
    fl_version = "0.1.0"
    fl_author = "Bradley Zeis"
    fl_author_email = "flamingoengine@gmail.com"
    fl_copyright = "2009 Bradley Zeis"
    fl_url = "http://flamingoengine.googlecode.com/"

    game_name = ""
    game_version = ""
    game_author = ""
    game_author_email = ""
    game_copyright = ""
    game_url = ""

    ##-------- File Data

    ##-------- Screen Data
    screen_title = "flamingo - {0}".format(fl_version)
    screen_size = None
    fullscreen = False

    screens = []

    painter = None
    
    master_eventlistener = None
    eventlistener = None

    ##-------- Clock Data
    master_clock = None
    logic_clock = None
    render_clock = None
    logic_fps = 64

    current_time = 0
    delta_time = 0          ## Time delta between current frame and last frame.

    ##-------- Caches
    tex_cache = {}

    ##-------- Game Data
    master_spr_group = None
    spr_groups = []
    usr_groups = []

    @classmethod
    def clear(cls):
        cls.master_spr_group.empty()
        for grp in cls.spr_groups:
            grp.empty()
        for grp in cls.usr_groups:
            grp.empty()

        cls.spr_groups = []
        cls.usr_groups = []


##-------- Global Names
GAME = None
